var objUser = {
	objData: {},

	checkAuth: function(callback) {
		var _self = this;

		objApi.get({
			url: "/user/status",
			success: function(data) {
				console.log(data);
				_self.objData = data.data;
				callback(true);
			},
			error: function(data){
				callback(false);
			}
		});
	},
	login: function(username, password){
		var _self = this;

		objApi.post({
			url: "/user/login",
			data: {"username": username, "password": password},
			success: function(data) {
				console.log(data);
				_self.objData = data.data;
				document.location = "/main/";
			}
		});
	},
	logout: function(redirect){
		//default -> redirect
		if(redirect == undefined) {
			redirect = true;
		}

		//call the api
		objApi.get({
			url: "/user/logout",
			success: function(){
				//if we should redirect to /login
				if(redirect == true) {
					document.location = "/login";
				}
			}
		});
	}
};